<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="demo"></div>
    <script>
        const Student = Vue.extend({
            name: 'student123222',// 名字是在控制台中显示的，首字母大小写都可以，但是显示最终都是大写
            data() {
                return {
                    name: '老张',
                    age: 20
                }
            },
            methods: {
                addAge() {
                    console.log('this: ', this)
                    console.log(this.__proto__.__proto__ === Vue.prototype)
                    console.log(Student.prototype.__proto__ === Vue.prototype)
                    // console.log(Student.prototype.__proto__ === vm.__proto__)
                    this.age += 1
                }
            },
            template: `
                <div>
                    <h3>学生</h3>
                    <p>name:{{name}}</p>
                    <p>age: {{age}}</p>
                    <p><button @click="addAge">age++</button></p>
                </div>
                `
        })
        Vue.config.productionTip = false
        new Vue({
            el: '#demo',
            components: {
                // 调用名：组件变量名
                // 调用名首字母大写不限制
                // 1. 单个单词：
                // 2. 多个单词：
                //    2-1. cabe-case: stduent-list
                //    2-2. 驼峰命名法: studentList
                // "student-list":Student
                StudentList:Student
                // studentList: Student
            },
            data: {},
            template: `
                    <div>
                        <h3>VM</h3>
                        <hr/>
                        <student-list/>
                    </div>
                `
        })
    </script>
</body>

</html>